package com.tms.operation.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.tms.operation.domain.TmsSilp;
import com.tms.operation.service.ITmsSilpService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 回单Controller
 *
 * @author ruoyi
 * @date 2024-10-28
 */
@RestController
@RequestMapping("/silp")
public class TmsSilpController extends BaseController
{
    @Autowired
    private ITmsSilpService tmsSilpService;

    /**
     * 查询回单列表
     */
    @RequiresPermissions("silp:silp:list")
    @GetMapping("/list")
    public TableDataInfo list(TmsSilp tmsSilp)
    {
        startPage();
        List<TmsSilp> list = tmsSilpService.selectTmsSilpList(tmsSilp);
        return getDataTable(list);
    }

    /**
     * 导出回单列表
     */
    @RequiresPermissions("silp:silp:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, TmsSilp tmsSilp)
    {
        List<TmsSilp> list = tmsSilpService.selectTmsSilpList(tmsSilp);
        ExcelUtil<TmsSilp> util = new ExcelUtil<TmsSilp>(TmsSilp.class);
        util.exportExcel(response, list, "回单数据");
    }

    /**
     * 获取回单详细信息
     */
    @RequiresPermissions("silp:silp:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tmsSilpService.selectTmsSilpById(id));
    }

    /**
     * 新增回单
     */
    @RequiresPermissions("silp:silp:add")
    @PostMapping
    public AjaxResult add(@RequestBody TmsSilp tmsSilp)
    {
        return toAjax(tmsSilpService.insertTmsSilp(tmsSilp));
    }

    /**
     * 修改回单
     */
    @RequiresPermissions("silp:silp:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody TmsSilp tmsSilp)
    {
        return toAjax(tmsSilpService.updateTmsSilp(tmsSilp));
    }

    /**
     * 删除回单
     */
    @RequiresPermissions("silp:silp:remove")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tmsSilpService.deleteTmsSilpByIds(ids));
    }
}
